package Java实训.第六天File文件和IO流;

import java.io.FileOutputStream;
import java.io.IOException;

public class Num1 {
    /*
    * 使用字节流分别实现把你心目中几个男神或女神的名字换行写到一个文本文件中。
    * */
    public static void main(String[] args) {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("C:\\Users\\gdq\\OneDrive\\桌面\\File文件夹\\Num1.txt");
            String str1 = "高代起";
            String str2 = "李东键";
            String str3 = "韩瑞杰";
            String str4 = "李柘宏";
            String str5 = "史乃齐";
            String str6 = "郭昊";
            fos.write(str1.getBytes());
            fos.write("\n".getBytes());
            fos.write(str2.getBytes());
            fos.write("\n".getBytes());
            fos.write(str3.getBytes());
            fos.write("\n".getBytes());
            fos.write(str4.getBytes());
            fos.write("\n".getBytes());
            fos.write(str5.getBytes());
            fos.write("\n".getBytes());
            fos.write(str6.getBytes());
            fos.write("\n".getBytes());
        } catch (IOException e) {
           e.printStackTrace();
        } finally {
            if (fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                fos = null;
            }

        }

    }
}
